# -*- coding: UTF-8 -*-
import  sys
import os
from tkinter import filedialog
from accessFile import  access
from log import  globalLog
from mkdir import  DirCmd

class OpenDirGraphicalInterface():
    def __init__(self):
        self.getOsTYpe()
        pass

    def getOsTYpe(self):
        osType = sys.platform

        if osType == "win32":
            self.OsType = "Windows"
        elif osType == "linux":
            self.OsType = "linux"

    def isWindows(self):
        return self.OsType == "Windows"

    def isLinux(self):
        return self.OsType == "linux"

    def openFileDialog(self,dir):
        access_ = access(dir)
        if not access_.isDir():
            globalLog.Error(dir,"is not dir ,can not open fileDialog")
            return

        if self.isWindows():
            self.openWindowsFileDialog(dir)
        elif self.isLinux():
            self.openLiuxFileDialog(dir)
        pass

    def openWindowsFileDialog(self,dir):
        return os.startfile(dir)
        pass

    def openLiuxFileDialog(self,dir):
        return os.startfile(dir)
        pass


OpenDirGraphicalInterfaceCmd = OpenDirGraphicalInterface()
if __name__ == "__main__":
    OpenDirGraphicalInterfaceCmd.openFileDialog("C:\\")
    # os.startfile("C:\\")